<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('用户查询报表')" />
    <th:block th:include="include :: layout-latest-css" />
    <th:block th:include="include :: ztree-css" />
</head>
<body class="gray-bg">
    <div class="ui-layout-west">
        <div class="box box-main">
            <div class="box-header">
                <div class="box-title">
                    <i class="fa icon-grid"></i> 组织机构
                </div>
                <div class="box-tools pull-right">
                    <button type="button" class="btn btn-box-tool" id="btnExpand" title="展开" style="display:none;"><i class="fa fa-chevron-up"></i></button>
                    <button type="button" class="btn btn-box-tool" id="btnCollapse" title="折叠"><i class="fa fa-chevron-down"></i></button>
                    <button type="button" class="btn btn-box-tool" id="btnRefresh" title="刷新部门"><i class="fa fa-refresh"></i></button>
                </div>
            </div>
            <div class="ui-layout-content">
                <div id="tree" class="ztree"></div>
            </div>
        </div>
    </div>
    <div class="ui-layout-center">
         <div class="container-div">
            <div class="row">
                <div class="col-sm-12 search-collapse">
                    <form id="formId">
                        <input type="hidden" id="deptId" name="deptId">
                        <div class="select-list">
                            <ul>
                                <li>
                                    <label>工号：</label>
                                    <input type="text" name="userNo"/>
                                </li>
                                <li>
                                    <label>姓名：</label>
                                    <input type="text" name="name"/>
                                </li>
                                <li>
                                    <label>性别：</label>
                                    <select name="sex" th:with="type=${@dict.getType('sys_user_sex')}">
                                        <option value="">所有</option>
                                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                    </select>
                                </li>
                                <li>
                                    <label>用户类别：</label>
                                    <select name="userType" th:with="type=${@dict.getType('basic_user_type')}">
                                        <option value="">所有</option>
                                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                    </select>
                                </li>
                                <li>
                                    <label>编制情况：</label>
                                    <select name="workDuty" th:with="type=${@dict.getType('basic_work_duty')}">
                                        <option value="">所有</option>
                                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                    </select>
                                </li>
                                <li>
                                    <label>取得职称等级：</label>
                                    <select name="obtainLevel" th:with="type=${@dict.getType('basic_post_level')}">
                                        <option value="">所有</option>
                                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                    </select>
                                </li>
                                <li>
                                    <label>聘任职称等级：</label>
                                    <select name="postLevel" th:with="type=${@dict.getType('basic_post_level')}">
                                        <option value="">所有</option>
                                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                    </select>
                                </li>
                                <li>
                                    <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                    <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                                </li>
                            </ul>
                        </div>
                    </form>
                </div>

                <div class="btn-group-sm" id="toolbar" role="group">
                    <a class="btn btn-warning" onclick="$.table.exportExcel()">
                        <i class="fa fa-download"></i> 导出
                    </a>
                </div>
                <div class="col-sm-12 select-table table-bordered">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: layout-latest-js" />
    <th:block th:include="include :: ztree-js" />
    <th:block th:include="include :: bootstrap-table-export-js" />
    <th:block th:include="include :: bootstrap-table-fixed-columns-js" />
    <script th:inline="javascript">
        var prefix = ctx + "report/position";

        var sexs = [[${@dict.getType('sys_user_sex')}]];
        var types = [[${@dict.getType('basic_user_type')}]];

        $(function() {
            var panehHidden = false;
            if ($(this).width() < 769) {
                panehHidden = true;
            }
            $('body').layout({ initClosed: panehHidden, west__size: 185 });
            // 回到顶部绑定
            if ($.fn.toTop !== undefined) {
                var opt = {
                    win:$('.ui-layout-center'),
                    doc:$('.ui-layout-center')
                };
                $('#scroll-up').toTop(opt);
            }
            queryUserList();
            queryDeptTree();
        });

        function queryUserList() {
            var options = {
                url: prefix + "/list",
                exportUrl: prefix + "/export",
                modalName: "用户信息",
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                showExport: true,
                fixedColumns: true,
                fixedNumber: 6,
                exportTypes: ['sql', 'excel'], // 导出的文件类型
                exportOptions: {
                    fileName: '职称聘任',    // 文件名称设置
                    mso: {
                        worksheetName: '职称聘任',
                        //修复导出数字不显示为科学计数法
                        onMsoNumberFormat: function (cell, row, col) {
                            return !isNaN($(cell).text())?'\\@':'';
                        }
                    }
                },
                columns: [
                    [
                        {
                            title : '基本信息',
                            align : 'center',
                            valign : 'center',
                            colspan : 7,
                            rowspan : 2
                        },
                        {
                            title : '职称聘任',
                            align : 'center',
                            valign : 'center',
                            colspan : 26,
                            rowspan : 1
                        }
                    ],
                    [
                        {
                            title : '一级职称',
                            align : 'center',
                            valign : 'center',
                            colspan : 2,
                            rowspan : 1
                        },
                        {
                            title : '二级职称',
                            align : 'center',
                            valign : 'center',
                            colspan : 2,
                            rowspan : 1
                        },
                        {
                            title : '三级职称',
                            align : 'center',
                            valign : 'center',
                            colspan : 2,
                            rowspan : 1
                        },
                        {
                            title : '四级职称',
                            align : 'center',
                            valign : 'center',
                            colspan : 2,
                            rowspan : 1
                        },
                        {
                            title : '五级职称',
                            align : 'center',
                            valign : 'center',
                            colspan : 2,
                            rowspan : 1
                        },
                        {
                            title : '六级职称',
                            align : 'center',
                            valign : 'center',
                            colspan : 2,
                            rowspan : 1
                        },
                        {
                            title : '七级职称',
                            align : 'center',
                            valign : 'center',
                            colspan : 2,
                            rowspan : 1
                        },
                        {
                            title : '八级职称',
                            align : 'center',
                            valign : 'center',
                            colspan : 2,
                            rowspan : 1
                        },
                        {
                            title : '九级职称',
                            align : 'center',
                            valign : 'center',
                            colspan : 2,
                            rowspan : 1
                        },
                        {
                            title : '十级职称',
                            align : 'center',
                            valign : 'center',
                            colspan : 2,
                            rowspan : 1
                        },
                        {
                            title : '十一级职称',
                            align : 'center',
                            valign : 'center',
                            colspan : 2,
                            rowspan : 1
                        },
                        {
                            title : '十二级职称',
                            align : 'center',
                            valign : 'center',
                            colspan : 2,
                            rowspan : 1
                        },
                        {
                            title : '十三级职称',
                            align : 'center',
                            valign : 'center',
                            colspan : 2,
                            rowspan : 1
                        }
                    ],
                    [
                    {
                        title: '序号',
                        align: 'center',
                        halign: 'center',
                        formatter: function (value, row, index) {
                            var options = $('#bootstrap-table').bootstrapTable('getOptions');
                            return options.pageSize * (options.pageNumber - 1) + index + 1;
                        }
                    },
                    {
                        field: 'userNo',
                        title: '工号'
                    },
                    {
                        field: 'name',
                        title: '姓名'
                    },
                    {
                        field: 'sex',
                        title: '性别',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(sexs, value);
                        }
                    },
                    {
                        field: 'idCard',
                        title: '身份证号'
                    },
                    {
                        field: 'deptName',
                        title: '所在科室'
                    },
                    {
                        field: 'userType',
                        title: '用户类别',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(types, value);
                        }
                    },
                        {
                            field: 'obtainTime1',
                            title: '取得时间'
                        },
                        {
                            field: 'engageTime1',
                            title: '聘任时间'
                        },
                        {
                            field: 'obtainTime2',
                            title: '取得时间'
                        },
                        {
                            field: 'engageTime2',
                            title: '聘任时间'
                        },
                        {
                            field: 'obtainTime3',
                            title: '取得时间'
                        },
                        {
                            field: 'engageTime3',
                            title: '聘任时间'
                        },
                        {
                            field: 'obtainTime4',
                            title: '取得时间'
                        },
                        {
                            field: 'engageTime4',
                            title: '聘任时间'
                        },
                        {
                            field: 'obtainTime5',
                            title: '取得时间'
                        },
                        {
                            field: 'engageTime5',
                            title: '聘任时间'
                        },
                        {
                            field: 'obtainTime6',
                            title: '取得时间'
                        },
                        {
                            field: 'engageTime6',
                            title: '聘任时间'
                        },
                        {
                            field: 'obtainTime7',
                            title: '取得时间'
                        },
                        {
                            field: 'engageTime7',
                            title: '聘任时间'
                        },
                        {
                            field: 'obtainTime8',
                            title: '取得时间'
                        },
                        {
                            field: 'engageTime8',
                            title: '聘任时间'
                        },
                        {
                            field: 'obtainTime9',
                            title: '取得时间'
                        },
                        {
                            field: 'engageTime9',
                            title: '聘任时间'
                        },
                        {
                            field: 'obtainTime10',
                            title: '取得时间'
                        },
                        {
                            field: 'engageTime10',
                            title: '聘任时间'
                        },
                        {
                            field: 'obtainTime11',
                            title: '取得时间'
                        },
                        {
                            field: 'engageTime11',
                            title: '聘任时间'
                        },
                        {
                            field: 'obtainTime12',
                            title: '取得时间'
                        },
                        {
                            field: 'engageTime12',
                            title: '聘任时间'
                        },
                        {
                            field: 'obtainTime13',
                            title: '取得时间'
                        },
                        {
                            field: 'engageTime13',
                            title: '聘任时间'
                        }]
                ]
            };
            $.table.init(options);
        }

        function queryDeptTree()
        {
            var url = ctx + "system/dept/treeData";
            var options = {
                url: url,
                expandLevel: 1,
                onClick : zOnClick
            };
            $.tree.init(options);

            function zOnClick(event, treeId, treeNode) {
                $("#deptId").val(treeNode.id);
                $.table.search();
            }
        }

        $('#btnExpand').click(function() {
            $._tree.expandAll(true);
            $(this).hide();
            $('#btnCollapse').show();
        });

        $('#btnCollapse').click(function() {
            $._tree.expandAll(false);
            $(this).hide();
            $('#btnExpand').show();
        });

        $('#btnRefresh').click(function() {
            queryDeptTree();
        });
    </script>
</body>
</html>